package com.linyaonan.labuladong._01_list._02;

/**
 * 基础链表结构
 */
public class ListNode {
    int val;
    ListNode next;
    ListNode(int x) { val = x; }

    @Override
    public String toString() {

        StringBuilder sb = new StringBuilder();
        ListNode p = this;
        while (p != null) {
            sb.append(" ").append(p.val).append(" ");
            p = p.next;
        }

        return sb.toString();
    }
}